package net.service.Impl;

import net.common.ServiceResponse;
import net.mapper.NoticeMapper;
import net.pojo.Notice;
import net.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author admin
 * @Date 2019/4/1 9:08
 */
@Service
@Transactional
public class NoticeServiceImpl implements NoticeService {
    @Autowired
    NoticeMapper noticeMapper;
    @Override
    public List<Notice> findAll() {
        return noticeMapper.findAll();
    }

    @Override
    public Notice findById(int n_id) {
        return noticeMapper.findById(n_id);
    }

    @Override
    public int updateById(Notice notice) {
        return noticeMapper.updateById(notice);
    }

    @Override
    public int deleteById(int n_id) {
        return noticeMapper.deleteById(n_id);
    }

    @Override
    public ServiceResponse editNotice(Notice notice) {
        int editNotice = noticeMapper.updateById(notice);
        if (editNotice>0){
            return ServiceResponse.createSuccessAndMessage("修改成功");
        }
        return ServiceResponse.createErrorAndMessage("修改失败");
    }

    @Override
    public int addNotice(Notice notice) {
        return noticeMapper.addNotice(notice);
    }

    @Override
    public Notice showById() {
        return noticeMapper.showById();
    }
}
